package algorithms.paixu.comparable;

import lombok.Data;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * @author Jim
 * @date 4:05 下午 2022/3/31
 * @description 比较人
 * @email:huwmz04153277@126.com
 */
@Data
public class PersonComparable implements Comparable<PersonComparable>{
    private String name;
    private Integer age;

    public PersonComparable(String name, Integer age) {
        this.name = name;
        this.age = age;
    }

    @Override
    public int compareTo(PersonComparable o) {
        return this.age - o.age;
    }

    public static void main(String[] args) {
        List<PersonComparable> personComparables = new ArrayList<>();;
        personComparables.add(new PersonComparable("ee",1));
        Collections.sort(personComparables);
    }
}
